/**
Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Test Framework for SEMF</title>
</head>
<body>
<div style="text-align:center"><h1>Test Framework for SEMF</h1></div>
<p>
<table width='100%'><tr><td width='30%'>&nbsp;</td><td>
<div style="border:solid 1px; height:30px; text-align:center">
<span style="float:left; ">
<a href="../core/lib/schema_generator.php?project_home=test/">Run All Schema Tests</a>
</span>
<span style="float:right">
<a href="../core/lib/pages_generator.php?project_home=test/">Run All Page Tests</a>
</span>

</div>
</td><td width='30%'>&nbsp;</td></tr></table>
</p>
<?php
$test_home = "./";
$files = array();
$d = dir($test_home);
// Loop through all of the files:
$i = 0;
while (false !== ($file = $d->read()))
{
	// If the file is not this file, and does not start with a '.' or '~'
	// and does not end in LCK, then store it for later display:
	if ( ($file{0} != '.') &&
		 ($file{0} != '~') &&
		 (substr($file, -3) != 'php') && is_dir($file))
	{
		if($file == "store")
		{
			continue;
		}
		$files[$i++] = $file;
	}
}
$top = 120;
$left = 50;
foreach($files as $test_module)
{
	$page_xml = $test_module."/"."test.xml";
	$result_dir = $test_module."/";
	$result_page = $test_module."/"."test_html.php";
	$project_home = "./";
	$module_xml =$test_module."/"."module.xml";
	
	$req_module = $test_module;
	
	$frame_top = $top + 60;

	echo "
	<span style=\"position:absolute; width:400px; left:${left}px; top:${top}px\"><h3 style=\"text-align:center\">${test_module}</h3></span> ";
	//echo "<iframe src= \"${result_page}\"
	// style=\"position:absolute; width:400px; height:240px; left:${left}px; top:${frame_top}px\">";

	echo "</iframe>";

	//$footer_top = $top + 310;
	$footer_top = $top + 70;
	$footer_left = $left + 60;
	
	$SEMF_ROOT = "../";
	$page_designer_dir = $SEMF_ROOT."page_designer/";

	if(is_file($module_xml))
	{
		$schema_generate_url = 
				"schema_generator.php?page_xml=${page_xml}&req_module=${req_module}&".
						"result_dir=${result_dir}&project_home=${project_home}";
	}
	$relative_page_xml = "./../test/".$page_xml;
	$relative_result_dir = "./../test/".$result_dir;
	$relative_project_home = "../test/".$project_home;
	$root_project_home = "test/".$project_home;
	
	$edit_url = $page_designer_dir."index.php?page_xml=${relative_page_xml}&".
					"result_dir=${relative_result_dir}&project_home=${root_project_home}";
	
	if(is_file($page_xml))
	{
		$generate_url = $page_designer_dir."generate_html.php?page_xml=${relative_page_xml}&".
						"result_dir=${relative_result_dir}&project_home=${relative_project_home}";
	}
	else
	{
		$generate_url = "";
	}
	echo "
	<div style=\"position:absolute; top:${footer_top}px; height:50px; left:${footer_left}px\">
	<a href=\"${schema_generate_url}\">Generate Schema</a> | <a href=\"${generate_url}\">Generate Page</a> | <a href=\"${edit_url}\">Edit</a> | <a href=\"${result_page}\">Preview</a>
	</div>";

	$left = ($left==50)?500:50;
	if($left == 50)
	{
		//$top += 370;
		$top += 130;
	}
}
?>

<!--<iframe style="position:absolute; width:400px; height:300px; left:50px; top:50px">
</iframe>
<div style="position:absolute; top:360px; height:50px; left:150px">
<a href="">Generate</a> | <a href="">Edit</a> | <a href="">Preview</a>
</div>-->
<!--
<iframe style="position:absolute; width:400px; height:300px; left:500px; top:50px">
	
</iframe>
<iframe style="position:absolute; width:400px; height:300px; left:50px; top:420px">
	
</iframe>
<iframe style="position:absolute; width:400px; height:300px; left:500px; top:420px">
	
</iframe>
-->
</body>
</html>
